Skip to content

fix: add authentication to GPU detail, topology, and history endpoints#696

Merged
Lightheartdevs merged 2 commits intoLight-Heart-Labs:mainfrom
yasinBursali:fix/gpu-endpoints-auth
Apr 6, 2026
Merged

fix: add authentication to GPU detail, topology, and history endpoints#696
Lightheartdevs merged 2 commits intoLight-Heart-Labs:mainfrom
yasinBursali:fix/gpu-endpoints-auth

Conversation

@yasinBursali
Copy link
Copy Markdown
Contributor

What

Add missing authentication to three GPU API endpoints that were accessible without credentials.

Why

GET /api/gpu/detailed, /api/gpu/topology, and /api/gpu/history had no Depends(verify_api_key) — every other non-health endpoint in dashboard-api requires auth. These endpoints expose per-GPU UUIDs, VRAM usage, topology, and utilization history.

How

  • Added Depends and verify_api_key imports to gpu.py
  • Added dependencies=[Depends(verify_api_key)] to all 3 route decorators
  • Uses decorator style matching updates.py convention

Testing

  • Python syntax: PASS
  • Manual: verify endpoints return 401 without Bearer token

Review

Critique Guardian: APPROVED (all four pillars clean)

Platform Impact

All platforms

Copy link
Copy Markdown
Collaborator

@Lightheartdevs Lightheartdevs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Audit Review

The fix is correct — these are the only three non-health endpoints in dashboard-api without auth. They expose GPU UUIDs, per-GPU VRAM usage, temperature, power draw, service assignments, and 5-minute utilization history.

The implementation is clean: imports Depends and verify_api_key, adds dependencies=[Depends(verify_api_key)] to the three route decorators. Matches the pattern used everywhere else in the codebase.

Blocking: Frontend doesn't pass auth headers

The dashboard frontend (useGPUDetailed.js) calls these endpoints without an Authorization header:

fetch('/api/gpu/detailed')  // No auth

Merging this PR alone will break the GPU panel on the dashboard with 401s. Needs a coordinated frontend change to pass Authorization: Bearer ${DASHBOARD_API_KEY}.

Either include the frontend fix in this PR, or open a companion frontend PR to merge simultaneously.

@yasinBursali
Copy link
Copy Markdown
Contributor Author

Thanks for the review! I investigated the concern about useGPUDetailed.js and wanted to clarify:

The dashboard frontend does use bare fetch() calls without explicit Authorization headers — you're right about that. However, these calls never need manual auth because nginx injects the Bearer token server-side for all /api/ requests.

In dream-server/extensions/services/dashboard/nginx.conf (line 29–31):

location /api/ {
    ...
    proxy_set_header Authorization "Bearer ${DASHBOARD_API_KEY}";
}

The entrypoint.sh substitutes the actual key value into the nginx config at container startup (read from DASHBOARD_API_KEY env var or /data/dashboard-api-key.txt).

This is the same mechanism that serves every other authenticated endpoint in the codebase — features.py, agents.py, workflows.py, setup.py, privacy.py, and 15+ endpoints in main.py all use Depends(verify_api_key), and none of the dashboard's JS hooks set auth headers explicitly. They all rely on the nginx injection.

Adding auth to these 3 GPU endpoints closes the last remaining auth gap in dashboard-api, which also protects the directly-exposed port 3002 against unauthorized LAN access (requests that bypass the nginx proxy entirely).

No frontend changes needed — the PR is safe to merge as-is.

All three GPU router endpoints were missing Depends(verify_api_key),
allowing unauthenticated access to GPU metrics, topology, and history
data. Every other non-health endpoint in the dashboard API requires
authentication via Bearer token.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yasinBursali yasinBursali force-pushed the fix/gpu-endpoints-auth branch from 6916408 to 9da34e2 Compare April 3, 2026 13:37
@yasinBursali
Copy link
Copy Markdown
Contributor Author

Rebased on latest main — no conflicts, cleaned up stray upstream commits from branch history.

Copy link
Copy Markdown
Collaborator

@Lightheartdevs Lightheartdevs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Audit: REQUEST CHANGES — will break frontend

The backend fix is correct and necessary — these GPU endpoints expose hardware identifiers and resource utilization data that should require auth. The Depends(verify_api_key) pattern matches every other authenticated endpoint in the codebase.

Blocker: Dashboard frontend sends no Authorization header to these endpoints.
useGPUDetailed.js (and related hooks) call /api/gpu/detailed, /api/gpu/topology, /api/gpu/history without an auth header. Merging this alone will break the GPU dashboard panel with 401 errors.

Fix: Needs a companion frontend PR that adds the Authorization header to these fetch calls. Both should merge together or the frontend PR should merge first.

…tion

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yasinBursali
Copy link
Copy Markdown
Contributor Author

Addressing review feedback

Re: Frontend doesn't pass auth headers — nginx already handles this. nginx.conf:29:

proxy_set_header Authorization "Bearer ${DASHBOARD_API_KEY}";

All /api/ requests get the Bearer token injected by nginx before reaching dashboard-api. This is the same mechanism used by every other authenticated endpoint — the frontend never passes auth headers directly.

Change made:

  • Added clarifying comment to useGPUDetailed.js: // Auth: nginx injects Authorization header for all /api/ requests (see nginx.conf).
  • This matches the identical comment already present in useVersion.js:3 and useVoiceAgent.js:10

No frontend fetch changes needed — merging the backend auth alone will not cause 401s.

Copy link
Copy Markdown
Collaborator

@Lightheartdevs Lightheartdevs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-audit: APPROVE — original concern resolved

Verified: nginx.conf line 29 injects Authorization: Bearer ${DASHBOARD_API_KEY} on all /api/ proxied requests. The frontend never needs manual auth headers — nginx handles it transparently. The architecture is sound: API key stays server-side, never exposed to the browser. Adding Depends(verify_api_key) to GPU endpoints is the correct backend hardening.

CI all green.

@Lightheartdevs
Copy link
Copy Markdown
Collaborator

Note: The Rust dashboard-api rewrite (#821) merged and deleted the Python files this PR modifies.

This PR modified routers/gpu.py which was deleted by the Rust rewrite. GPU endpoint authentication needs to be verified/added in the Rust codebase at crates/dashboard-api/src/routes/gpu.rs.

Please rebase or rewrite against the current main branch.

@Lightheartdevs Lightheartdevs merged commit 127a27c into Light-Heart-Labs:main Apr 6, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants